import { registerMap } from "echarts"
import chinaGeojson from "@/assets/json/china.json"

export function OptionFun(echartData: any) {
    // @ts-ignore
    registerMap("china", chinaGeojson)
    const mapName = "china"

    const option = {
        backgroundColor: '#1b2735',
        geo: {
            map: mapName,
            aspectScale: 0.75, //长宽比
            zoom: 1.2,
            roam: false,
            itemStyle: {
                areaColor: {
                    type: 'radial',
                    x: 0.5,
                    y: 0.5,
                    r: 0.8,
                    colorStops: [{
                        offset: 0,
                        color: '#00544A' // 0% 处的颜色
                    }, {
                        offset: 1,
                        color: '#00B180'  // 100% 处的颜色
                    }],
                    globalCoord: true // 缺省为 false
                },
                shadowColor: 'rgb(58,115,192)',
                shadowOffsetX: 5,
                shadowOffsetY: 6
            },
            regions: [{
                name: '南海诸岛',
                itemStyle: {
                    areaColor: 'rgba(0, 10, 52, 1)',
                    borderColor: 'rgba(0, 10, 52, 1)',
                    opacity: 0,
                    label: {
                        show: false,
                        color: "#009cc9",
                    }
                },
            }],
            emphasis: {
                itemStyle: {
                    areaColor: '#2AB8FF',
                    borderWidth: 0,
                    color: 'green',
                    label: {
                        show: false
                    }
                }
            }
        },
        series: [
            {
                type: 'map',
                map: mapName,
                roam: false,
                label: {
                    show: false,
                    color: '#1DE9B6'
                },
                itemStyle: {
                    borderColor: 'rgb(147, 235, 248)',
                    borderWidth: 1,
                    areaColor: {
                        type: 'radial',
                        x: 0.5,
                        y: 0.5,
                        r: 0.8,
                        colorStops: [{
                            offset: 0,
                            color: '#00544A' // 0% 处的颜色
                        }, {
                            offset: 1,
                            color: '#00B180'  // 100% 处的颜色
                        }],
                        globalCoord: true // 缺省为 false
                    }
                },
                emphasis: {
                    label: {
                        // color: 'rgb(183,185,14)'
                        color: 'red'
                    },
                    itemStyle: {
                        areaColor: 'rgb(46,229,206)',
                        //    shadowColor: 'rgb(12,25,50)',
                        borderWidth: 0.1
                    }

                },
                zoom: 1.2
            },
            {
                type: 'effectScatter',
                coordinateSystem: 'geo',
                showEffectOn: 'render',
                zlevel: 1,
                rippleEffect: {
                    period: 15,
                    scale: 4,
                    brushType: 'fill'
                },
                label: {
                    formatter: '{b}',
                    position: 'right',
                    offset: [15, 0],
                    color: '#1DE9B6',
                    show: true
                },
                itemStyle: {
                    color: '#1DE9B6'/* function (value){ //随机颜色
                                return "#"+("00000"+((Math.random()*16777215+0.5)>>0).toString(16)).slice(-6);
                                }*/,
                    shadowBlur: 10,
                    shadowColor: '#333'
                },
                emphasis: {
                    scale: true
                },
                symbolSize: 2,
                data: echartData.points
            },
            {
                type: 'lines',
                zlevel: 2,
                effect: {
                    show: true,
                    period: 4, //箭头指向速度，值越小速度越快
                    trailLength: 0.4, //特效尾迹长度[0,1]值越大，尾迹越长重
                    symbol: 'arrow', //箭头图标
                    symbolSize: 7, //图标大小
                },
                lineStyle: {
                    color: '#1DE9B6'
                                /* function (value){ //随机颜色
                                
                                ['#f21347','#f3243e','#f33736','#f34131','#f34e2b',
                                '#f56321','#f56f1c','#f58414','#f58f0e','#f5a305',
                                '#e7ab0b','#dfae10','#d5b314','#c1bb1f','#b9be23',
                                '#a6c62c','#96cc34','#89d23b','#7ed741','#77d64c',
                                '#71d162','#6bcc75','#65c78b','#5fc2a0','#5abead',
                                '#52b9c7','#4fb6d2','#4ab2e5']
         return "#"+("00000"+((Math.random()*16777215+0.5)>>0).toString(16)).slice(-6);
         }*/,
                    width: 1, //线条宽度
                    opacity: 0.1, //尾迹线条透明度
                    curveness: .3 //尾迹线条曲直度
                },
                data: echartData.lines
            }
        ]
    }
    return option;
}
